home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 13267 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  42 lines

  1. Newsgroups: comp.lang.c
  2. Path: netcom.com!russells
  3. From: russells@netcom.com (Russell Salsbury)
  4. Subject: Re: Question-how print time from unix
  5. Message-ID: <russellsDpDstt.7KL@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. References: <4jahpf$dpp@cloner2.ix.netcom.com>
  8. Date: Fri, 5 Apr 1996 08:56:17 GMT
  9. Sender: russells@netcom3.netcom.com
  10.  
  11. martypro@ix.netcom.com (Marty) writes:
  12.  
  13. >Ok here is a dumb question I'm sure:
  14.  
  15. >Below is the relevant code I am using to input the time into a structure 
  16. >element and can't find the appropriate conversion character to use with 
  17. >printf to print it, that is if that is how you print it.  Any help you 
  18. >can give me will be greatly appreciated.
  19.  
  20. >struct queue
  21. >  {char name[MAX1];
  22. >   time_t time_in;
  23. >   int priority;
  24. >  }customer[MAX2];
  25.  
  26. >customer[inctr].time_in=time(NULL);
  27.  
  28. use ctime.
  29.  
  30. #include <stdio.h>
  31. #include <time.h>
  32.  
  33. int main()
  34. {
  35.     time_t tm;
  36.     time(&tm);
  37.     printf("Current time: %s", ctime(&tm));    /* ctime string has \n */
  38.     return 0;
  39. }
  40.  
  41. Ryan    russells@netcom.com
  42.